#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/3/15 0:27
# @Author : XXX
# @Site : 
# @File : day-5.py
# @Software: PyCharm
'''
    将列表中的偶数全部移除
    ll = [1,2,24,5,6,66,7,8,88,9,12,11,16,13]

    遍历列表？  index  下标索引
'''

ll = [1, 2, 24, 5, 6, 66, 7, 8, 88, 9, 12, 11, 16, 13]
# 复制列表
# ll_copy = ll.copy()
#
# for i in ll_copy:
#     if i%2 == 0:
#         ll.remove(i)
#
# print(ll)

'''
列表推导式   x for x in ll if x%2!=0
x 代表的是 每个被遍历的元素  
for x in ll 遍历整个列表
if x%2 != 0 
'''
a = [x for x in ll if x % 2 != 0]
print(a)
'''

    1、定义乐器类Instrument，包括makeSound()方法，此方法中乐器声音："乐器发出美妙的声音！"
    2、定义乐器类的子类：二胡Erhu、钢琴Piano和小提琴Violin
        二胡Erhu声音："二胡拉响人生"
        钢琴Piano声音："钢琴美妙无比"
        小提琴Violin声音："小提琴来啦"
'''


class Instrument:

    def makeSound(self):
        print("乐器发出美妙的声音！")


class ErHu(Instrument):

    def makeSound(self):
        print("二胡拉响人生")


class Piano(Instrument):

    def makeSound(self):
        print("钢琴美妙无比")


class Violin(Instrument):

    def makeSound(self):
        print("小提琴来了")


def sound(a):
    a.makeSound()


i = Instrument()
erhu = ErHu()
p = Piano()

sound(p)